package com.pk.platform.business.report.web;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.pk.platform.business.common.service.IClaService;
import com.pk.platform.business.core.web.GenericAction;
import com.pk.platform.business.report.service.ITuitionReportService;
import com.pk.platform.business.report.vo.TuitionReportVO;
import com.pk.platform.domain.common.Cla;
import com.pk.platform.util.DateConverter;
import com.pk.platform.util.StringConverter;

public class TuitionReportAction extends GenericAction {

	ITuitionReportService tuitionReportService;
	
	TuitionReportVO trvo = new TuitionReportVO();
	
	private IClaService claService;
	
	private List<Cla> classList = new ArrayList<Cla>();
	
	List<Map<String, Object>> title = null;
	
	List<Map<String, Object>> value = null;
	
	List<Map<String, Object>> total = null;
	
	List<Map<String, Object>> years = null;
	
	InputStream excelStream;
	
	private int tableWidth;
	
	public String getTuitionReport(){
		classList = claService.queryClassList(kindergartenId);
		trvo.setKindergartenId(kindergartenId);
		if(!StringConverter.isNotNull(trvo.getPeriodStart()))
			trvo.setPeriodStart(DateConverter.getCurrentYearStr());
		if(!StringConverter.isNotNull(trvo.getPeriodEnd()))
			trvo.setPeriodEnd(DateConverter.getCurrentYearStr());
		lp = tuitionReportService.getTuitionReportList(trvo, pager,showType);
		title=tuitionReportService.getCharge();
		total=tuitionReportService.getReportTotalList(trvo, showType);
		years=tuitionReportService.getYears();
		tableWidth = 1500 + 100 * title.size();
		return SUCCESS;
	}
	
	public String getTuitionReportExcel(){
		if(!StringConverter.isNotNull(trvo.getPeriodStart()))
			trvo.setPeriodStart(DateConverter.getCurrentYearStr());
		if(!StringConverter.isNotNull(trvo.getPeriodEnd()))
			trvo.setPeriodEnd(DateConverter.getCurrentYearStr());
		trvo.setKindergartenId(kindergartenId);
		excelStream = tuitionReportService.getExcelInputStream(trvo,showType);
		return FILE;
	}
	
	
	public InputStream getExcelStream() {
		return excelStream;
	}

	public void setExcelStream(InputStream excelStream) {
		this.excelStream = excelStream;
	}

	public IClaService getClaService() {
		return claService;
	}

	public void setClaService(IClaService claService) {
		this.claService = claService;
	}

	public List<Cla> getClassList() {
		return classList;
	}

	public void setClassList(List<Cla> classList) {
		this.classList = classList;
	}

	public ITuitionReportService getTuitionReportService() {
		return tuitionReportService;
	}

	public void setTuitionReportService(ITuitionReportService tuitionReportService) {
		this.tuitionReportService = tuitionReportService;
	}

	public TuitionReportVO getTrvo() {
		return trvo;
	}

	public void setTrvo(TuitionReportVO trvo) {
		this.trvo = trvo;
	}

	public List<Map<String, Object>> getTitle() {
		return title;
	}

	public void setTitle(List<Map<String, Object>> title) {
		this.title = title;
	}
	
	public List<Map<String, Object>> getValue() {
		return value;
	}

	public void setValue(List<Map<String, Object>> value) {
		this.value = value;
	}

	public List<Map<String, Object>> getTotal() {
		return total;
	}

	public void setTotal(List<Map<String, Object>> total) {
		this.total = total;
	}

	public List<Map<String, Object>> getYears() {
		return years;
	}

	public void setYears(List<Map<String, Object>> years) {
		this.years = years;
	}

	public int getTableWidth() {
		return tableWidth;
	}

	public void setTableWidth(int tableWidth) {
		this.tableWidth = tableWidth;
	}

}
